Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the HISTIGNORE Bash variable #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xty
Copy link

@xty xty commented Mar 4, 2023

The following passage from the Bash Reference Manual provides justification for the proposed changes:

HISTIGNORE subsumes the function of HISTCONTROL. A pattern of ‘&’ is identical to ignoredups, and a pattern of ‘[ ]*’ is identical to ignorespace. Combining these two patterns, separating them with a colon, provides the functionality of ignoreboth.

The relevant section as it stands:

dotfiles/.bash_profile

Lines 57 to 63 in 8936892

export HISTCONTROL="ignoredups" # no duplicate entries, but keep space-prefixed commands
export HISTSIZE=100000 # big big history (default is 500)
export HISTFILESIZE=$HISTSIZE # big big history
type shopt &> /dev/null && shopt -s histappend # append to history, don't overwrite it
# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"

Specifically, this PR is aimed at ironing out these kinks:

  1. Having both & in HISTIGNORE and ignoredups in HISTCONTROL is redundant.
  2. Assuming the intention was to preserve commands with a leading space (as indicated by the comment in Line 57), the inclusion of [ ]* in HISTIGNORE would be self-defeating.

* preserve commands with a leading space in Bash history as intended
* remove the `&` pattern which serves the same purpose of `ignoredups`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant